/********************************************
* Copyrigt (C) rumi
* Module: bsp_iic.h
*********************************************/
#ifndef bsp_iic_H
#define bsp_iic_H
#include "esp_log.h"
#include "driver/i2c_master.h"
#include "esp_check.h"
#include "esp_types.h"
#include "esp_mac.h"

#define PORT_NUMBER -1

#define I2C_EEPROM_MAX_TRANS_UNIT (48)

typedef struct {
    i2c_device_config_t subdevice_device;  /*!< Configuration for device */
    uint8_t addr_wordlen;               /*!< block address wordlen */
    uint8_t write_time_ms;              /*!< eeprom write time, typically 10ms*/
} i2c_subdevice_config_t;

struct i2c_subdevice_t {
    i2c_master_dev_handle_t i2c_dev;      /*!< I2C device handle */
    uint8_t addr_wordlen;                 /*!< block address wordlen */
    uint8_t *buffer;                      /*!< I2C transaction buffer */
    uint8_t write_time_ms;                /*!< I2C eeprom write time(ms)*/
};

typedef struct i2c_subdevice_t i2c_subdevice_t;
typedef struct i2c_subdevice_t *i2c_subdevice_handle_t;

extern i2c_subdevice_handle_t  my_subdevice_handle;
void bsp_iic_init();
esp_err_t i2c_subdevice_read(i2c_subdevice_handle_t subdevice_handle, uint32_t address, uint8_t *data, uint32_t size);
#endif
/********************************************
 * End of file
*********************************************/